package firear.tvutils.ws.serv.req;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.util.Log;

import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.protocol.HttpContext;
import org.apache.http.protocol.HttpRequestHandler;
import firear.tvutils.ws.Constants;
import firear.tvutils.ws.WSApplication;
import firear.tvutils.ws.serv.support.HttpGetParser;
import firear.tvutils.ws.serv.support.Progress;
import firear.tvutils.ws.util.CallMedlaPlayer;

import java.io.IOException;
import java.net.URLDecoder;
import java.util.Map;

//am start -n com.mxtech.videoplayer.pro/.ActivityScreen -d '/sdcard/SmallVideo/500b858366f7f6a9cfe7e37195efd500.mp4'


public class HttpVideoPushHandler implements HttpRequestHandler {


    @Override
    public void handle(HttpRequest httpRequest, HttpResponse httpResponse, HttpContext httpContext) throws HttpException, IOException {

        HttpGetParser parser = new HttpGetParser();
        Map<String, String> params = parser.parse(httpRequest);
        String url = params.get("url");
        url = URLDecoder.decode(url, Constants.Config.ENCODING);
        Log.e("tt", "get play url = " + url);

        CallMedlaPlayer.callMxPlayer(url, WSApplication.getInstance().getApplicationContext());

        //http://192.169.133.26:7766/video?url=http%3A%2F%2Fa.a
        HttpEntity entity = null;
        String contentType = "text/html;charset=" + Constants.Config.ENCODING;

        httpResponse.setStatusCode(HttpStatus.SC_OK);
        Progress.clear();

    }
}
